package com.es.esapi.controller.fileUpload;

import com.es.esapi.common.CommonResponse;
import com.es.esapi.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import java.util.UUID;

@RestController
@RequestMapping("upload")
public class UploadController {
    @Resource
    UploadService uploadService;
    /**
     * 上传方式2 MultipartFile 上传
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping("post")
    public CommonResponse upload2(@RequestParam("file") MultipartFile file, @RequestParam("title") String title) throws Exception {
        return uploadService.uploadFile(file,title);

    }
}
